package cls.elmp.atf.servlet;

import com.service.atf.adder.service.AdderService;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by IntelliJ IDEA.
 * User: luotao
 * Date: 12-3-17
 * Time: PM9:56
 * To change this template use File | Settings | File Templates.
 */
public class ServletMain extends HttpServlet {
    AdderService adderService;

    @Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);

//    String xml=FileUtil.Loader.loadResc("/cls/elmp/atf/socket/conf/config_web_adder.xml");
//    XmlWapper wapper=XmlWapper.parse(xml);
//    ATFConstants.initParam(wapper);
//    MockTFDBService tfdbService = new MockTFDBService(true);
//    adderService=new AdderService(1000000, 5000000);
//
//    adderService.setItfdbService(tfdbService);
//    adderService.init();
        /*  ReplyService replyService = new ReplyService(100000,1000000,tfdbService);
        String xml_reply=FileUtil.Loader.loadResc("/cls/elmp/atf/socket/conf/config_web_reply.xml");
        XmlWapper wapper_reply=XmlWapper.parse(xml_reply);
        replyService.init(wapper_reply);*/
    }


    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("GBK");
        PrintWriter out = resp.getWriter();
        try {
//      BussLogin login=BaseTest.createLogin("62010000000000000001");
//      byte[] bb=login.object2Byte();
//      ResultAdderWrite resultAdderWrite=adderService.writeData(bb);
//      out.print("write result : "+resultAdderWrite);
            out.print("OK");
        } catch (Exception e) {
            out.write("ERROR");
        } finally {
            out.flush();
            out.close();
        }

    }
}
